home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
dev
/
basic
/
ZClipBoard.lha
/
Clipboard.asc
next >
Wrap
Text File
|
1997-10-13
|
3KB
|
155 lines
;
; Using the Amiga's Clipboard.device with Blitz2
;
; by Benoit Socias -- bsocias@ulb.ac.be
;
; Feel free to copy this code into your program
;
;
; ClipOpen{} : call it to open the Clipboard ^_^;;
; (automatically called by ClipRead and ClipWrite)
;
; ClipClose{}: call it to close the Clipboard
; (automatically called by ClipRead and ClipWrite)
;
; ClipWrite{s.s} : writes string s to Clipboard
;
; s.s=ClipRead{} : reads Clipboatd into string s
;
; accessing exec level devices
;
; provides two things :
; ClipWrite{s.s} puts an IFF string in the clipboard
; =ClipRead.s{} reads an IFF string from the clipboard
;
NEWTYPE.Node:*ln_Succ.Node:*ln_Pred:ln_Type.b:ln_Pri:*ln_Name.b:End NEWTYPE
NEWTYPE.List:*lh_Head.Node:*lh_Tail:*lh_TailPred:lh_Type.b:l_pad:End NEWTYPE
NEWTYPE.MsgPort
mp_Node.Node
mp_Flags.b
mp_SigBit.b
*mp_SigTask.w
mp_MsgList.List
End NEWTYPE
NEWTYPE.Message
mn_Node.Node
*mn_ReplyPort.MsgPort
mn_Length.w
End NEWTYPE
NEWTYPE.ClipboardUnitPartial
cu_Node.Node
cu_UnitNum.l
End NEWTYPE
NEWTYPE.IOStdReq
io_Message.Message
*io_Device.b ;Device
; *io_Unit.ClipboardUnitPartial
*io_Unit.b
io_Command.w
io_Flags.b
io_Error.b
io_Actual.l
io_Length.l
*io_Data.b
io_Offset.l
;add particulars to device here
io_ClipID.l
End NEWTYPE
#_INVALID=0:#_RESET=1:#_READ=2:#_WRITE=3:#_UPDATE=4
#_CLEAR=5:#_STOP=6:#_START=7:#_FLUSH=8:#_NONSTD= 9
;
;initialise messageport and iorequest for talking to device
;
DEFTYPE .IOStdReq clipio
DEFTYPE .MsgPort clipport
clipsig.l=0
.ClipOpen
Statement ClipOpen{}
SHARED clipio,clipport,clipsig
clipport\mp_Node\ln_Type=4
clipport\mp_MsgList\lh_Head=&clipport\mp_MsgList\lh_Tail
clipport\mp_MsgList\lh_TailPred=&clipport\mp_MsgList\lh_Head
clipio\io_Message\mn_Node\ln_Type=5
clipio\io_Message\mn_ReplyPort=&clipport
clipio\io_Message\mn_Length=SizeOf.IOStdReq
d.s="clipboard.device"
If OpenDevice_(d,0,clipio,0)<>0 Then End
clipsig.l=AllocSignal_(-1):If clipsig<0 Then End
clipport\mp_SigBit=clipsig
clipport\mp_SigTask=FindTask_(0)
End Statement
.ClipClose
Statement ClipClose{}
SHARED clipio,clipsig
CloseDevice_ clipio
FreeSignal_ clipsig
End Statement
.ClipWrite
Statement ClipWrite{s.s}
SHARED clipio
ClipOpen{}
sodd.s=s
If Len(s) MOD 2 Then sodd+Chr$(0)
a.s="FORM"+Mkl$(12+Len(sodd))+"FTXTCHRS"+Mkl$(Len(s))+sodd
USEPATH clipio
\io_Command=#_WRITE
\io_Data=&a
\io_Length=Len(a)
\io_ClipID=0
\io_Offset=0
\io_Error=0
SendIO_ clipio
\io_Command=#_UPDATE
SendIO_ clipio
ClipClose{}
End Statement
.f_ClipRead
Function.s ClipRead{}
SHARED clipio
s.s=SPACE$(4096)
ClipOpen{}
USEPATH clipio
\io_Command=#_READ
\io_Data=&s
\io_Length=4096
\io_ClipID=0
\io_Offset=0
SendIO_ clipio
r.s=Left$(s,\io_Actual)
\io_Offset=10000
SendIO_ clipio
If(Left$(r,4)="FORM")
If(Mid$(r,9,8)="FTXTCHRS")
r=Mid$(r,21,Cvl(Mid$(r,17,4)))
Else
r=""
EndIf
EndIf
ClipClose{}
Function Return r
End Function